#include <stdio.h>
#include<math.h>
#define rows 4
#define cols 3

void linearSearch2D(int a[][cols],int integer , int *indrow ,int *indcol);

int main() {
	
 int i,j,integer,a[rows][cols],indcol,indrow;
 
 printf("ENTER the integer elements at a 4*3 2D-array:");
 
 
 for(j=0;j<cols;j++){
     for(i=0;i<rows;i++)
    scanf("%d",&a[i][j]) ;
   } 
   
   printf("Enter the integer value to search for:");
   
   scanf("%d",&integer);
   
    linearSearch2D(a,integer, &indrow , &indcol);
    
    if(indrow!=-1)
    printf("The value %d exists in the array at (row %d,column %d)",integer,indrow,indcol);
   else
   printf("The value %d does not exist in the array",integer);
   
    return 0;
}

void linearSearch2D(int a[][cols] ,int integer ,int *indrow ,int *indcol){
    int i ,j;
    
 for(j=0;j<cols;j++){
     for(i=0;i<rows;i++)
     
       if(a[i][j]==integer){
       *indrow=i;
       *indcol=j;
       return;
       }
 }
  *indrow=-1;
  *indcol=-1;
}
